<?php
if(!check_manager_login()) exit('无权查看，请登录!');
require_once(MODEL_PATH.DS.'News.php');
$News = new News();
$go = isset($_GET['go'])?trim($_GET['go']):'';
$id = isset($_GET['id'])?(int)trim($_GET['id']):'';
if(check_post()){
	$cate_id = trim($_POST['cate_id']);
	$name = trim($_POST['name']);
	$status = $_POST['status'];
	$time = date('Y-m-d H:i:s');
	if(!$name) redirect('index.php?mod=news&act=cate','名称不能为空');
	if($cate_id){
		$result = $News->updateCate($cate_id,$name,$status);
		$msg = '更新成功!';
	}else{
		$result = $News->addCate($name,$status,$time);
		$msg = '添加成功!';
	}
	if($result){
		redirect('index.php?mod=news&act=cate',$msg);
	}
}
$cate_all = $News->getAllNewsCate();

if($go == 'edit'){
	if($id){
		$cate_info = $News->getNewsCateById($id);
	}
}

if($go == 'del'){
	if($id){
		$result = $News->delNewsCateById($id);
		if($result){
			redirect('index.php?mod=news&act=cate','删除成功！');
		}
	}
}

include load_tpl('news_cate');
?>